package com.cxg.fairy.ec.main.personal.score;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.alibaba.fastjson.JSONObject;
import com.cxg.fairy.ui.recycler.MultipleItemEntity;
import com.diabin.latte.ec.R;

import java.util.List;

/**
 * Created by Administrator on 2018/4/10.
 */

public class ScoreListAdapter extends ArrayAdapter{

    public ScoreListAdapter(@NonNull Context context, int resource, @NonNull List objects) {
        super(context, resource, objects);
    }

    @NonNull
    @Override
    public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {

        final MultipleItemEntity entity = (MultipleItemEntity) getItem(position);
        final JSONObject orderCommetnObj = new JSONObject();
        orderCommetnObj.clear();
        final String reason = entity.getField("reason");
        final String time = entity.getField("time");
        final String point = entity.getField("point");

        LinearLayoutCompat view = (LinearLayoutCompat) LayoutInflater.from(parent.getRootView().getContext()).inflate(R.layout.item_score_list, parent,false);
        AppCompatTextView mScoreDesc = (AppCompatTextView) view.findViewById(R.id.tv_score_desc);
        AppCompatTextView mScoreAmount = (AppCompatTextView) view.findViewById(R.id.tv_score_amount);
        AppCompatTextView mScoreTime = (AppCompatTextView) view.findViewById(R.id.tv_score_time);

        mScoreDesc.setText(reason);
        mScoreAmount.setText(point);
        mScoreTime.setText(time);
        return view;
    }

}
